mini_debugger =false;
/*************************************自定义验证方法 start*****************/
/* 是否英文 */
mini.VTypes["enErrorText"] = "请输入英文";
mini.VTypes["en"] = function (v) {
    var re = new RegExp("^[a-zA-Z\_]+$");
    if (re.test(v)) return true;
    return false;
}

mini.VTypes["enAndNumErrorText"] = "必须输入英文+数字";
mini.VTypes["enAndNum"] = function (v) {
    var re = new RegExp("^[0-9a-zA-Z\_]+$");
    if (re.test(v)) return true;
    return false;
}
mini.VTypes["zhErrorText"] = "请输入中文";
mini.VTypes["zh"] = function (v) {
    return isChinese(v);
}
mini.VTypes["notZhErrorText"] = "请不要输入中文";
mini.VTypes["notZh"] = function (v) {
    return !isChinese(v);
}

/* 是否汉字 */
function isChinese(v) {
    var re = new RegExp("^[\u4e00-\u9fa5]+$");
    if (re.test(v)) return true;
    return false;
}


mini.VTypes["idcardErrorText"] = "必须输入15~18位数字";
mini.VTypes["idcard"] = function (v) {
    var pattern = /\d*/;
    if (v.length < 15 || v.length > 18 || pattern.test(v) == false) {
       return false;
    }else{
    	return true;
    }
}
/*************************自定义验证方法 end****************************/
/*************************格式化grid中日期显示格式 end****************************/
function onShowDateToGrid(e) {
	var value = e.value;
	if (value) return mini.formatDate(new Date(value), 'yyyy-MM-dd');
	return "";
}
function onShowDateTimeToGrid(e) {
	var value = e.value;
	if (value) return mini.formatDate(value, 'yyyy-MM-dd HH:mm:ss');
	return "";
}
/***********************设置  输入/只读  表单*****************start********************************/
function labelModel(form) {
	var fields = form.getFields();                
	for (var i = 0, l = fields.length; i < l; i++) {
		var c = fields[i];
		if (c.setReadOnly) c.setReadOnly(true);     //只读
		if (c.setIsValid) c.setIsValid(true);      //去除错误提示
		if (c.addCls) c.addCls("asLabel");          //增加asLabel外观
	}
}
function inputModel(form) {
	var fields = form.getFields();
	for (var i = 0, l = fields.length; i < l; i++) {
		var c = fields[i];
		if (c.setReadOnly) c.setReadOnly(false);
		if (c.removeCls) c.removeCls("asLabel");
	}
	mini.repaint(document.body);
}
function setFormModel(form,isEdit){
	if(isEdit){
		inputModel(form);
	}else{
		labelModel(form);
	}
}
